package com.xinqi.modules.chat.enums.group;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.xinqi.common.base.enums.BasicEnum;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @version V1.0
 * @Title: 用户标识
 * @ClassName: com.xinqi.modules.chat.enums.group.GroupUserLeaderFlagEnum.java
 * @Description:
 * @Copyright 星齐科技（云南）有限公司 - Powered By 技术部
 * @author: yyzhen
 * @date: 2023/8/23 10:36
 */
public enum GroupUserLeaderFlagEnum implements BasicEnum {

    ONE(1, "群主"),

    TWO(2, "管理员"),

    THREE(3, "普通用户");

    @Getter(onMethod_ = {@JsonValue})
    private final int code;

    @Getter
    private final String describe;

    GroupUserLeaderFlagEnum(int code, String describe) {
        this.code = code;
        this.describe = describe;
    }

    public static List<Map<String, String>> getSelectList() {
        List<Map<String, String>> list = new ArrayList<>();
        for (GroupUserLeaderFlagEnum leaderFlagEnum : GroupUserLeaderFlagEnum.values()) {
            Map<String, String> map = new HashMap<>();
            map.put("code", leaderFlagEnum.getCode() + StringUtils.EMPTY);
            map.put("describe", leaderFlagEnum.getDescribe());
            list.add(map);
        }
        return list;
    }

    @JsonCreator
    public static GroupUserLeaderFlagEnum of(Integer code) {
        return BasicEnum.of(GroupUserLeaderFlagEnum.class, code);
    }
}
